﻿<!-- #include file="cjf.asp" -->
<!--#include file="conn.asp"-->
<!--#include file="inc/CHAR.INC"-->
<%
comicid=request("comicid")
set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from comics where id="&comicid
rs.open sql,conn,1,3
mhmc=rs("mhmc")
rs.close%><html>
<head>
    <title>漫画采集</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="images/style.css" type="text/css" rel="stylesheet">
    <script language="JavaScript" src="inc/js.js" type="text/javascript"></script>
    <style type="text/css">
<!--
.STYLE1 {color: #999999}
-->
</style>
</head>
<body>
    <center>
        <table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
            <tr>
                <td height="30" bgcolor="e7e7e7">
                    <div align="left">
                        <strong>
                            <%=mhmc%>章节采集 </strong>
                    </div>
                </td>
            </tr>
            <form action="" method="get" name="formcj">
            <input name="comicid" type="hidden" value="<%=request("comicid")%>">
            <tr>
                <td bgcolor="#FFFFFF">
                    &nbsp;选择采集来源站点：
                    <select name="cjid" size="1" id="select" class="cjid">
                        <%  set rs2=server.CreateObject("ADODB.RecordSet")
	  cjid=request("cjid")
sql2="select * from cjxm"
rs2.Open sql2,conn,1,1
if rs2.EOF then
response.write("<option value=""0"">没有相关采集站点</option>")
else
while not rs2.EOF
response.write("<option value="&rs2("id")&"")
if cjid=rs2("id") then
response.write(" selected")
end if
response.write(">"&rs2("xmmc")&"</option>")                    
rs2.MoveNext
wend
rs2.close
end if %>
                    </select>
                </td>
            </tr>
            <tr>
                <td height="30" bgcolor="#FFFFFF">
                    <input name="act" type="hidden" value="cj">
                    章节名称:
                    <input name="zjmc" type="text" id="zjmc" value="<%=request("zjmc")%>" size="10">
                    &nbsp;输入对方ID号:ID1
                    <input name="id1" type="text" id="id1" value="<%=request("id1")%>" size="10">
                    ID2
                    <input name="id2" type="text" id="id2" value="<%=request("id2")%>" size="10">
                    <input name="submit2" type="submit" class="Submit" value="开始采集">
                </td>
            </tr>
            </form>
        </table>
        <table width="98%" border="0" align="center" cellpadding="8" cellspacing="1" bgcolor="#CCCCCC"
            style="margin-top: 5px">
            <tr>
                <td width="100%" colspan="3" bgcolor="#FFFFFF">
                    <%if request("act")="cj" then
       comicid=request("comicid")
	  cjid=request("cjid")
	  id1=request("id1")
	  id2=request("id2")
	  zjmc=request("zjmc")
	  if zjmc="" then
		  Response.Write "章节名称不能为空&nbsp;&nbsp;<A HREF=# onclick=""Javascript:history.back(-1)""><FONT  COLOR=#FF0000>请点这里返回</FONT></A>"
	  Response.End  
end if
	  if IsNumeric(id1)=false or IsNumeric(id2)=false then
		  Response.Write "ID号必须为数字&nbsp;&nbsp;<A HREF=# onclick=""Javascript:history.back(-1)""><FONT  COLOR=#FF0000>请点这里返回</FONT></A>"
	  Response.End  
end if

sql="select * from cjxm where id="&cjid
rs.open sql,conn,1,3
xmmc=rs("xmmc")
xmfd=rs("xmfd")
picxz=rs("picxz")
xmsx=rs("xmsx")
fnbody=rs("fnbody")
fnfg=rs("fnfg")
fnid=rs("fnid")
fnmc=rs("fnmc")
mhurl=rs("mhurl")
mhbody=rs("mhbody")
mhmc=rs("mhmc")
mhtp=rs("mhtp")
mhtpurl=rs("mhtpurl")
mhzz=rs("mhzz")
mhjs=rs("mhjs")
mhzt=rs("mhzt")
mhfg=rs("mhfg")
mhzj=rs("mhzj")
mhzjid=rs("mhzjid")
zjurl=rs("zjurl")
zjbody=rs("zjbody")
zjsx=rs("zjsx")
zjfy=rs("zjfy")
zjtpurlsx=rs("zjtpurlsx")
zjtpsl=rs("zjtpsl")
zjtpsurl=rs("zjtpsurl")
zjtpurl=rs("zjtpurl")
rs.close%>
                    <%
if request("page")<>"" then
page=request("page")
else
page=1
end if
   pageid=page
   zjurl=Replace(zjurl,"[ID1]",""&id1&"") 
   zjurl=Replace(zjurl,"[ID2]",""&id2&"") 
   zjurl=Replace(zjurl,"[ID3]",""&pageid&"")
   if picxz=true then
   Set fso = Server.CreateObject("Scripting.FileSystemObject")
if fso.folderexists(server.mappath("../comicdata/"&comicid&"\"&foldername))=false then
Fso.Createfolder(server.mappath("../comicdata/"&comicid&"\"&foldername))
end if
if fso.folderexists(server.mappath("../comicdata/"&comicid&"/"&zjmc&"\"&foldername))=false then
Fso.Createfolder(server.mappath("../comicdata/"&comicid&"/"&zjmc&"\"&foldername))
end if
savepath="../comicdata/"&comicid&"/"&zjmc&"/"&pageid&".jpg"
end if
nextpage=page+1
url=zjurl
if url="" then
   Response.write "&nbsp;请输入漫画页地址&nbsp;&nbsp;<A HREF=# onclick=""Javascript:history.back(-1)""><FONT  COLOR=#FF0000>请点这里返回</FONT></A>"
   Response.End
end if
   MusicMake
Sub MusicMake

MakeIMG
End Sub

Sub MakeIMG
Dim k:k=0




url=bqtf1(url)
zjbody=bqtf1(zjbody)
zjtpsl=bqtf1(zjtpsl)
zjtpurl1=bqtf1(zjtpurl1)

zjbody1=Split(zjbody,"$")
zjtpsl1=Split(zjtpsl,"$")
zjtpurl1=Split(zjtpurl,"$")

zlp=GetHttp(url) 

'采集相关信息开始
body=GetStr(zlp,zjbody1(0),zjbody1(1))
zjtpsl2=GetStr(body,zjtpsl1(0),zjtpsl1(1))
zjtpurl2=GetStr(body,zjtpurl1(0),zjtpurl1(1))
zjtpurl3=zjtpsurl&zjtpurl2
'开始写入数据
'===================================================
'RString=DeHttpdata(zlp,"'[^<>'']*','[^<>'']*','[^<>""]*'")
if xmfd=true then
getPICurl=""&web_url&"/inc/picpj.asp?url="&zjtpurl3
else
getPICurl=""&zjtpurl3&""
end if
Response.write  "本章节:&nbsp;"&zjmc&"&nbsp;共有&nbsp;"&zjtpsl2&"&nbsp;张图片"
Sql="Select * From zj where zjmc='"&trim(zjmc)&"'"
Rs.Open Sql,Conn,1,3
if rs.eof then
Rs.AddNew
rs("cid")=comicid
rs("zjmc")=zjmc
rs("tpadd")=comicid&"/"&zjmc&"/"
rs("tps")=zjtpsl2
rs("tpf")=0
rs("adddate")=now()
rs("tpurl")=zjtpurl2&"|"
rs("hits")=0
rs("cjitemid")=cjzj_id
rs.update
Response.write "数据保存成功"
else
if instr(""&rs("tpurl")&"",""&zjtpurl2&"")<>0  then
Response.write "图片地址已存在"
else
rs("tpurl")=rs("tpurl")&zjtpurl2&"|"
rs.update
Response.write "图片地址更新成功"
end if
rs.update
Response.write "数据已存在，图片地址更新成功"
end if

rs.close

if picxz=true then
if fso.FileExists(server.mappath(savepath))=false then
Response.write "下载图片："&zjtpurl3&" 保存为："&savepath&""
call saveimg(getPICurl,savepath)
else
Response.write "下载图片："&zjtpurl3&" 保存为："&savepath&" &nbsp;<font color=blue>图片存在，已跳过</font>"
end if
else
Response.write "<font color=blue>漫画图片没有下载</font>"
end if

if pageid=zjtpsl2 then
Response.write "&nbsp;<font color=red>本章节采集完成</font>"
else
MakeNexttp
end if
End Sub
Sub MakeNexttp
Response.write "<meta http-equiv=""refresh"" content=""0;url='zj_cj.asp?zjmc="&zjmc&"&comicid="&comicid&"&cjid="&cjid&"&act=cj&id1="&id1&"&id2="&id2&"&page="&nextpage&""">"
end sub
                    %>
                    <%else%>
                    <span class="STYLE1">正在等待开始采集漫画数据....</span>
                    <%end if%>
                </td>
            </tr>
        </table>
    </center>
</body>
</html>
